﻿<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> <%@ Page Language="C#" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" MasterPageFile="~/_layouts/application.master"      %> <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register Tagprefix="psw" Namespace="PhilWicklund.com.FacebookParts.Data" Assembly="PhilWicklund.com.FacebookParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b52bc83f173fb28c" %> 

<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="PhilWicklund.com.FacebookParts.Data" %>


<asp:Content ID="Content1" contentplaceholderid="PlaceHolderPageTitle" runat="server">
	Facebook Connect Document Sharing
</asp:Content>
<asp:Content ID="Content2" contentplaceholderid="PlaceHolderPageTitleInTitleArea" runat="server">
	Facebook Connect Document Sharing
</asp:Content>
<asp:content ID="Content4" contentplaceholderid="PlaceHolderPageDescription" runat="server">
After the modal dialog appears, click the back button in your browser. You may have to allow
</asp:content>
<asp:content ID="Content5" contentplaceholderid="PlaceHolderMain" runat="server">
  <script runat="server">
      string url = "";
      string apikey = "";
	  protected override void OnPreRender(EventArgs e)
	  {
		  base.OnPreRender(e);

		  try
		  {
              SPSecurity.RunWithElevatedPrivileges(delegate
              {
                  string listid = this.Page.Request.QueryString["List"].ToString();
                  string id = this.Page.Request.QueryString["ID"].ToString();
                  SPWeb web = SPContext.Current.Web;
                  SPList list = web.Lists[new Guid(listid)];
                  SPListItem item = list.GetItemById(int.Parse(id));
                  url = web.Url + "/" + item.Url;
              });
              FacebookSettings settings = FacebookSettings.GetSettings(
                        SPContext.Current.Site.RootWeb.Url
                    );

              apikey = settings.APIKey.ToString();
		  }
		  catch (Exception ex)
		  {
			  Label1.Text = "Error: Could not load list item URL: " + ex.Message;
			  Label1.Visible = true;
		  }
	  }
</script>

<strong>
	<asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="Red" Text="Label"
		Visible="False"></asp:Label><br />
</strong>

<strong>
	<asp:Label ID="Label2" runat="server" Font-Bold="True" ForeColor="Black" Text="You may have to allow for popups for the Sharing dialog to appear:"
		></asp:Label><br />
</strong>
<br />
<asp:Image runat="server" ImageUrl="/_layouts/images/happenings/popup.png" />

<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">    FB.init("<%=apikey%>", "/xd_receiver.htm"); </script>

<script type="text/javascript">
    function run() { setTimeout("javascript:FB.Connect.showShareDialog('<%=url %>', function() { });", 1000); }
    window.onload = run;
</script>

</asp:content>
